<template>
  <div class="mod-config">
    <el-table :data="dataList" border v-loading="dataListLoading" style="width: 100%;">
      <el-table-column prop="name" header-align="center" align="center" label="姓名">
      </el-table-column>
      <el-table-column prop="roomNum" header-align="center" align="center" label="旧房号">
      </el-table-column>
      <el-table-column prop="newRoomNum" header-align="center" align="center" label="新房号">
      </el-table-column>
      <el-table-column prop="price" header-align="center" align="center" label="原房价">
      </el-table-column>
      <el-table-column prop="newPrice" header-align="center" align="center" label="新房价">
      </el-table-column>
      <el-table-column prop="arrivalsTime" header-align="center" align="center" label="入住时间" width="156">
      </el-table-column>
      <el-table-column prop="changeTime" header-align="center" align="center" label="换房时间" width="156">
      </el-table-column>
      <el-table-column prop="operator" header-align="center" align="center" label="操作员" width="150">
      </el-table-column>
      <el-table-column fixed="right" header-align="center" align="center" width="150" label="操作">
        <template slot-scope="scope">
          <el-button type="text" size="small" @click="print(scope.row)">打印</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination style="text-align: right;margin-top: 8px;" @size-change="sizeChangeHandle" @current-change="currentChangeHandle" :current-page="pageIndex"
      :page-sizes="[10, 20, 50, 100]" :page-size="pageSize" :total="totalPage" layout="total, sizes, prev, pager, next, jumper">
    </el-pagination>

  </div>
</template>

<script>
  export default {
    data() {
      return {
        dataForm: {
          key: ''
        },
        dataList: [],
        pageIndex: 1,
        pageSize: 10,
        totalPage: 0,
        dataListLoading: false,
        dataListSelections: [],
        addOrUpdateVisible: false
      }
    },
    components: {

    },
    activated() {
      this.getDataList()
    },
    methods: {
      init(floorRoomId) {
        this.dataForm.floorRoomId = floorRoomId
        this.$nextTick(() => {
          this.getDataList();
        })
      },
      // 获取数据列表
      getDataList() {
        this.dataListLoading = true
        this.$http({
          url: this.$http.adornUrl('/hotel/thotelfloorroomchangerecord/list'),
          method: 'get',
          params: this.$http.adornParams({
            'page': this.pageIndex,
            'limit': this.pageSize,
            'floorRoomId': this.dataForm.floorRoomId,
            'key': this.dataForm.key
          })
        }).then(({
          data
        }) => {
          if (data && data.code === 0) {
            this.dataList = data.page.list
            this.totalPage = data.page.totalCount
          } else {
            this.dataList = []
            this.totalPage = 0
          }
          this.dataListLoading = false
        })
      },
      print(row) {
        this.$emit('pringing',row)
      },
      // 每页数
      sizeChangeHandle(val) {
        this.pageSize = val
        this.pageIndex = 1
        this.getDataList()
      },
      // 当前页
      currentChangeHandle(val) {
        this.pageIndex = val
        this.getDataList()
      },
    }
  }
</script>
